package com.scujj.util;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@Component
public class CheckToken {
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    public boolean check(String token) {
        if(token==null){
            return false;
        }
        String idString = stringRedisTemplate.opsForValue().get(token);
        if(idString==null){
            return false;
        }else {
            stringRedisTemplate.opsForValue().set(token,idString);
            return true;
        }
    }
}
